package com.woniuxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.woniuxy.bean.UserVo;
import com.woniuxy.mapper.UserMapper;
import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String telephone, String password) {
        return userMapper.selectUserByTelephone(telephone,password);
    }
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public List<User> findUsersByPage(UserVo userVo) {
        PageHelper.startPage(userVo.getPageSize(),userVo.getCount());
        return this.userMapper.selectUsersByUser(userVo);
    }

    @Override
    public void addUser(User user) {
        this.userMapper.insertUser(user);
    }
}
